# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=pev
pkgver=0.82
pkgrel=0
pkgdesc="PE file analysis toolkit"
url="https://github.com/mentebinaria/readpe"
arch="all"
license="GPL-2.0-or-later AND MIT AND BSD-2-Clause"
makedepends="bsd-compat-headers linux-headers openssl-dev>3"
options="!check" # fixme
checkdepends="bash perf"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/mentebinaria/readpe/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/readpe-$pkgver"

# secfixes:
#   0.82-r0:
#     - CVE-2021-45423

build() {
	make prefix=/usr
}

# Check() code from
# https://github.com/void-linux/void-packages/blob/master/srcpkgs/pev/template#L37
_real_check() {
	for f in /usr/lib/python3.11/distutils/command/*.exe; do
		tests/run.sh pe32 "$f"
	done
}

check() {
	export LD_LIBRARY_PATH="$PWD/src/build"
	ln -sf ../../lib/libpe/libpe.so src/build/libpe.so.1
	! _real_check | tee /dev/stderr | grep -q 'NOK$'
}

package() {
	make prefix=/usr DESTDIR="$pkgdir" install
}

sha512sums="
4ace735d785d2d1af5fb192b3041a1df42f0efce28ed9e44f746f67f1fb900c596ae602f4e19e472df6eefe81dc2c9083c715898306bc7faa6a4d45d8fe02235  pev-0.82.tar.gz
"
